package com.guaoran.jvm.analyse.problem;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author gucheng
 * @Description
 *  内存泄漏
 * 2019-03-21 11:21
 */
public class OOMHeapTest {
    public static void main(String[] args){
        oom();
    }
    //-Xms200m  -Xmx200m  -XX:+HeapDumpOnOutOfMemoryError
    private static void oom(){
        Map<String, OOMBean> map = new HashMap<String, OOMBean>();
        Object[] array = new Object[1000000];
        for(int i=0; i<1000000; i++){
            String d = new Date().toString();
            OOMBean o = new OOMBean(d, i);
            map.put(i+"_oom", o);
            array[i] = o;
        }
    }
}